/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 */

import { NewAppScreen } from '@react-native/new-app-screen';
import { Alert, Button, StatusBar, StyleSheet, Text, useColorScheme, View } from 'react-native';
import ChildCom from './ChildCom';
import { useState } from 'react';

function App3() {
  
// set+变量名  为一个更新对应变量渲染的函数
let [num, setNum]=useState(0)
      const addFun = () => {
        // num++
        setNum(num+1) //通过与弹框对比发现set函数是异步的，系统出于性能考量
         // num++  setNum(num) 这样就避免异步，但一般不这样用只是这里用提示框对比出来这个情况了
        console.log('提示num: ' +num)
        Alert.alert('提示', 'num: ' + num)
      }
  return (
    <View style={styles.container}>
   <Button title={"点击"+num} onPress={addFun} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    marginTop: 50,
  },
});

export default App3;
